package homework2;

import java.util.Scanner;

public class RunGo {
    public static void main(String[] args) {
        try {
            HOME();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    public static void HOME() throws Exception {
        System.out.println("欢迎登录学生信息管理系统");
//        homework.HomeWorkStudentTestSystem homeWorkStudentTestSystem = new homework.HomeWorkStudentTestSystem();
        HomeWorkStudentTestSystem homeWorkStudentTestSystem = new HomeWorkStudentTestSystem();
        homeWorkStudentTestSystem.logon();
        Scanner scanner = new Scanner(System.in);

        System.out.println("请输入你要进行的业务");
        System.out.println("查询请输入1");
        System.out.println("添加请输入2");
        System.out.println("更新请输入3");
        System.out.println("删除请输入4");


        int a = scanner.nextInt();

            switch (a) {

                case 1:


                    Student selectData = HomeWorkStudentTestSystem.selectData("select * from student where sname=?", Student.class, "李同学999");
                    System.out.println("selectData = " + selectData);
                    break; // 可选
                case 2:
                     scanner = new Scanner(System.in);


                    System.out.println("请输入要添加的学生姓名");
                    String sname = scanner.next();
                    System.out.println("请输入要添加的学生性别");
                    String ssex = scanner.next();
                    System.out.println("请输入要添加的学生年龄");
                    String sage = String.valueOf(Integer.valueOf(scanner.next()));
                    System.out.println("请输入要添加的学生专业");
                    String sdepartment = scanner.next();


//


                    int insert = HomeWorkStudentTestSystem.insert("insert into student  values(null,?,?,?,?)", sname, ssex, Integer.valueOf(sage), sdepartment);
                    System.out.println("insert = " + insert);
                    HOME();
                    // 可选
                // 可以有更多的case子句
                case 3:
                    scanner = new Scanner(System.in);


                    System.out.println("请输入要更新的学生姓名");
                    sname = scanner.next();
                    System.out.println("将该学生的年龄更新为");
                     sage = String.valueOf(Integer.valueOf(scanner.next()));
                    HomeWorkStudentTestSystem.updateData("update student set sage=? where sname=? ",sage,sname);


                    break;
                case 4:

                     scanner = new Scanner(System.in);
                    System.out.println("请输入要删除的学生姓名");
                     sname = scanner.next();

                   HomeWorkStudentTestSystem.deleteDb("delete from student where sname=?",sname);

                case 5:





                    break;



            }









//        HomeWorkStudentSystem homeWorkStudentSystem = new HomeWorkStudentSystem();
//        homeWorkStudentSystem.deleteDb();
//        homeWorkStudentSystem.insert();
//
//
//        homeWorkStudentSystem.selectData();

    }}
